import { request } from "../../request/index.js"

//Page Object
Page({
    data: {
        //轮播图数组
        swiperList: [],
        //分类数组
        cateList: [],
        //楼层数组
        floorList: [],
        url: ""
    },
    hanleCick(e) {

        const { url } = e.currentTarget.dataset;
        const query = url.split('=')[1];

        this.setData({
            url: "/pages/goods_list/index?query=" + query
        })
        console.log(this.data.url);
        wx.navigateTo({
            url: this.data.url,
        });

    },
    //options(Object)
    onLoad: function(options) {
        // 1. 发送异步请求获取轮播图数据
        // var reqTask = wx.request({
        //     url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
        //     success: (result) => {
        //         this.setData({
        //             swiperList: result.data.message
        //         })
        //     }
        // });
        this.getSwiperList();
        this.getCateList();
        this.getFloorList();

    },
    //获取轮播图数据
    getSwiperList() {
        request({ url: '/home/swiperdata' })
            .then(result => {
                this.setData({
                    swiperList: result
                })
            })
    },
    //获取导航分类数据
    getCateList() {
        request({ url: '/home/catitems' })
            .then(result => {
                this.setData({
                    cateList: result
                })
            })
    },
    getFloorList() {
        request({ url: '/home/floordata' })
            .then(result => {
                this.setData({
                    floorList: result
                })
            })
    },
    onReady: function() {

    },
    onShow: function() {

    },
    onHide: function() {

    },
    onUnload: function() {

    },
    onPullDownRefresh: function() {

    },
    onReachBottom: function() {

    },
    onShareAppMessage: function() {

    },
    onPageScroll: function() {

    },
    //item(index,pagePath,text)
    onTabItemTap: function(item) {

    }
});